package drexel.services;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Component;

@Component
public class DBAccessService {
	
	// TODO: Replace all lists with actual DB access code and return full
	// movie XML that was originally loaded in from the file system

	public List<String> getAllMoviesByDirector (String director) {
		
		System.out.println ("Director to search for: [" + director + "]");
		
		List<String> allMovies = new ArrayList<String> ();
		
		allMovies.add (TEST_XML);
		
		return allMovies;
	}
	
	public List<String> getAllMoviesByActor (String actor) {
		
		System.out.println ("Actor to search for: [" + actor + "]");
		
		List<String> allMovies = new ArrayList<String> ();
		
		allMovies.add (TEST_XML);
		
		return allMovies;
	}
	
	public List<String> getAllMovies () {
		
		List<String> allMovies = new ArrayList<String> ();
		
		allMovies.add (TEST_XML);
		
		return allMovies;
	}
	
	public String loadMovie (String movieToLoad) {
		
		System.out.println ("File Content: " + movieToLoad);
		
		return "Done";
	}
	
	// Test Data Only
	
	private static final String TEST_XML = 
		"<W4F_DOC>" +
		  "<Movie>" +
		    "<Title>39 Steps, The</Title>" +
		    "<Year>1935</Year>" +
		    "<Directed_By>" +
		      "<Director>Alfred Hitchcock</Director>" +
		    "</Directed_By>" +
		    "<Genres>" +
		      "<Genre>Mystery</Genre>" +
		      "<Genre>Thriller</Genre>" +
		      "<Genre>(more)</Genre>" +
		    "</Genres>" +
		    "<Cast>" +
		      "<Actor>" +
		        "<FirstName>Robert</FirstName>" +
		        "<LastName>Donat</LastName>" +
		      "</Actor>" +
		    "</Cast>" +
		  "</Movie>" +
		"</W4F_DOC>";
}
